#include "Camera.h"

void Camera::SetPos( const sf::Vector2f& p )
{
	pos = p; 
	if(pos.x < hlim.x) pos.x = hlim.x; else if(pos.x+size.x > hlim.y) pos.x = hlim.y - size.x;
	if(pos.y < vlim.x) pos.y = vlim.x; else if(pos.y+size.y > vlim.y) pos.y = vlim.y - size.y;
}

bool Camera::IsOnCamera( const sf::Vector2f& pos1, const sf::Vector2f& size1 ) const
{
	return (    pos1.x < pos.x + size.x &&
		pos1.x + size1.x > pos.x &&
		pos1.y < pos.y + size.y &&
		pos1.y + size1.y > pos.y         );
}

Camera::Camera( float x, float y, float w, float h )
{
	pos = sf::Vector2f(x,y); size = sf::Vector2f(w,h);
}

Camera::Camera( sf::Vector2f Pos, sf::Vector2f Size ) : pos(Pos), size(Size)
{

}

Camera::Camera()
{
	hlim.y = size.x = 640; 
	vlim.y = size.y = 480;
}